<template>
  <el-row :gutter="20">
    <ms-card title="字典表" save-button="添加" :col=12 @saveClick="$refs['dictType'].handleOpenDialog()">
      <dict-type @clickRow="handleEmitDictType" ref="dictType" />
    </ms-card>
    <ms-card title="字典关联表" save-button="添加" :col=12 @saveClick="handleOpenChildrenDialog">
      <dict-children v-if="dictTypeId.length > 0" :dict-type="dictTypeId" ref="dictChildren" />
    </ms-card>
  </el-row>
</template>

<script>
import MsCard from '@/common/card/components'
import DictType from './dictType'
import DictChildren from './dictChildren'
export default {
  components: {
    DictChildren,
    DictType,
    MsCard
  },
  data() {
    return {
      dictTypeId: ''
    }
  },
  methods: {
    handleEmitDictType(val) {
      this.dictTypeId = val
    },
    handleOpenChildrenDialog() {
      this.dictTypeId.length > 0 ? this.$refs['dictChildren'].handleOpenDialog() : this.$message({
        message: '请选择父级字典后在进行操作',
        type: 'warning'
      })
    }
  }
}
</script>
